//
//  LPTool.m
//  单例
//
//  Created by liupan on 2016/12/10.
//  Copyright © 2016年 liupan. All rights reserved.
//

#import "LPTool.h"

@implementation LPTool
//提供全局变量
static LPTool *_instance;
//ARC环境
+ (instancetype)shareTool{

    return [[self alloc]init];
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone{

//    //第一种写法，懒加载
//    if (_instance == nil) {
//        _instance = [super allocWithZone:zone];
//    }
//    return _instance;
    //GCD第二种写法，只调用一次
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });
    return _instance;
}

-(id)copyWithZone:(NSZone *)zone{

    return  _instance;
}
- (id)mutableCopyWithZone:(NSZone *)zone{

    return _instance;
}
//MRC环境
//- (oneway void)release{
//
//}
//- (instancetype)retain{
//
//    return _instance;
//}
//- (NSUInteger)retainCount{
//    
//    return  MAXFLOAT;
//}
@end
